#!/bin/bash

# install_lib.sh

# 获取当前脚本所在的绝对路径
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" &>/dev/null && pwd)

# 引用 common_utils.sh
source "$SCRIPT_DIR/common_utils.sh"
DEFAULT_BUILD_PROFILE="profiles_Ubuntu_20.04"
DEFAULT_ACTION="all"
DEFAULT_CONANFILE=""
DEFAULT_LIB_NAME="sqilte/3.45"
# 调用 run_build 函数

ACTION="install"
CONANFILE=""
BUILD_PROFILE="${1:-$DEFAULT_BUILD_PROFILE}" 
LIB_NAME="${2:-$DEFAULT_LIB_NAME}"
BUILD_TYPE="${3:-Debug}" # it can be Release or Debug


# 如果输入的是单字符 D 或 d，转换为 Debug
if [[ "$BUILD_TYPE" == "D" || "$BUILD_TYPE" == "d" ]]; then
    BUILD_TYPE="Debug"
fi

# 如果输入的是单字符 R 或 r，转换为 Release
if [[ "$BUILD_TYPE" == "R" || "$BUILD_TYPE" == "r" ]]; then
    BUILD_TYPE="Release"
fi


PY_RECIPE_PATH="$SCRIPT_DIR/../conanfile_install.py"    
sed -i "0,/self.requires(.*)/s#self.requires(.*)#self.requires(\"${LIB_NAME}\")#" "$PY_RECIPE_PATH"



echo "PY_RECIPE_PATH: $PY_RECIPE_PATH"
echo "LIB_NAME: $LIB_NAME"
# 调用 run_build 函数
run_build "$BUILD_PROFILE" "$ACTION" "$CONANFILE" "$BUILD_TYPE"

